package com.runjian.rundo.iot.agent.iec104.consts;

import lombok.Getter;

/**
 * 传送原因枚举
 */
@Getter
public enum Cot {
    NO_USE(0, "未用"), PER_CYC(1, "周期、循环"), BACK(2, "背景扫描"), SPONT(3, "突发(自发)"), START_ACT(4, "初始化完成"), REQ(5, "请求或者被请求"), ACT(6, "激活"),
    ACTCON(7, "激活确认"), DEACT(8, "停止激活"), DEACTCON(9, "停止激活确认"), ACTTERM(10, "激活终止"), FILE_TRANS(13, "文件传输"), INTROGEN(20, "响应站召唤"), ELECTRIC_ENERGY(37, "响应电能量总召唤");

    private short code;
    private String name;

    Cot(int code, String name) {
        this.code = (short)code;
        this.name = name;
    }

    public static Cot valueOfCode(short code) {
        for (Cot value : Cot.values()) {
            if (value.code == code) {
                return value;
            }
        }
        return null;
    }

}
